﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes {
    import Engine.Classes.*;
    import Engine.Managers.*;
    import Events.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import Transactions.*;
    import Classes.util.*;
    import Classes.sim.*;
    import __AS3__.vec.*;
    import Modules.quest.Managers.*;
    import Display.*;
    import Modules.quest.Display.QuestManager.*;
    import Display.NeighborUI.*;
    import Modules.stats.data.*;
    import Classes.doobers.*;
    import Modules.storage.*;
    import Classes.inventory.*;
    import Modules.franchise.data.*;
    import Modules.stats.experiments.*;
    import Display.hud.components.*;
    import Modules.stats.*;
    import Classes.Managers.*;
    import flash.net.*;
    import Engine.*;
    import Classes.zbar.*;
    import Modules.stats.types.*;
    import L10n.*;
    import Display.hud.*;
    import com.adobe.utils.*;

    public class Player extends SavedObject implements IStatsTarget {

        public static const FAKE_USER_ID:int = -1;
        public static const FAKE_USER_ID_STRING:String = FAKE_USER_ID.toString();
        public static const NOT_COMPENSATED:int = 0;
        public static const COMPENSATED_NON_GIFT_CARD:int = -1;
        public static const COMPENSATED_GIFT_CARD:int = 1;

        public const SEEN_EXTENDED_PERMISSIONS_ANY:String = "any";
        public const OUT_OF_ENERGY_POPUP_DELAY:Number = 5000;
        public const ENERGY_OVERFLOW_POPUP_DELAY:Number = 1000;
        private const COINFLIP_FEED:int = 0;
        private const COINFLIP_REQUEST:int = 1;

        public var name:String;
        public var snUser:SocialNetworkUser;
        public var mutualFriendsDialog:MutualFriendInviteDialog;
        protected var m_friends:Array;
        protected var m_appFriends:Array;
        protected var m_hasFriendsSNData:Boolean = false;
        protected var m_level:Number = 1;
        protected var m_xp:Number = 0;
        protected var m_gold:Number;
        protected var m_cash:Number;
        protected var m_energy:Number;
        protected var m_heldEnergy:Number = 0;
        protected var m_socialLevel:Number = 1;
        protected var m_socialXp:Number = 0;
        protected var m_visitorEnergy:Number;
        protected var m_energyMax:Number;
        protected var m_expansionsPurchased:Number;
        protected var m_expansionCostLevel:Number;
        protected var m_lastEnergyCheck:Number;
        public var lastVisitedMap:String = null;
        public var m_licenses:Dictionary;
        protected var m_limitedItems:Dictionary;
        protected var m_unparsedNeighborsData:Array;
        protected var m_neighbors:Array;
        protected var m_maxNeighbors:int = 0;
        protected var m_franchiseUnlocksPurchased:int = 0;
        protected var m_hasMadePurchase:Boolean = false;
        protected var m_franchiseMoneyReturned:int = 0;
        protected var m_topFriends:Array;
        protected var m_missionItemInventory:Array;
        protected var m_gifts:Object;
        protected var m_promos:Object;
        private var m_inventory:Inventory;
        private var m_requestInventory:RequestInventoryComponent;
        private var m_storageComponent:StorageComponent;
        private var m_collections:Object;
        private var m_completedCollections:Object;
        private var m_collectionTradeIns:Object;
        public var wishlist:Array;
        private var m_commodities:Commodities;
        protected var m_options:Object;
        private var m_isNew:Boolean = false;
        private var m_creationTimestamp:uint = 0;
        private var m_isFirstDay:Boolean = false;
        private var m_hasVisitFriend:Number = 0;
        private var m_allowQuests:Boolean = false;
        public var m_flagContainer:Array;
        private var m_seenFlags:Object;
        private var m_seenSessionFlags:Object;
        private var m_news:Array;
        protected var m_homeIslandSize:int;
        private var m_randomRollCounter:int;
        private var m_randomRollCounterMap:Dictionary;
        private var m_stateObservers:Array;
        protected var m_lastWarpTime:int = 0;
        private var m_populationObservedOnLastExpansion:int = 0;
        protected var m_lastActionTime:int;
        protected var m_cityName:String;
        protected var m_pendingCityName:String;
        protected var m_socialNetworkId:int;
        protected var m_dailyBonusManager:DailyBonusManager;
        protected var m_outOfEnergyCount:uint = 0;
        protected var OOE_Coin:int = -1;
        protected var m_handlingOutOfEnergy:Boolean = false;
        protected var m_doOutOfEnergyFeed:Boolean = false;
        protected var m_doOutOfEnergyRequest:Boolean = false;
        protected var m_dailyVisits:uint;
        public var additionalWareHouseSlots:int = 0;
        protected var m_playerTimestamps:Object;
        protected var m_currentTimestamp_EventID:String;
        protected var m_previousTimestamp_EventID:String;
        protected var m_compensationFlag:int = 0;
        private var m_randomModifierOverride:int = -1;
        private var m_randomModifierGroupOverride:int = -1;
        protected var m_numQuestsLoading:int = 0;
        private var m_savedQuestSequence:Array;
        private var m_questManagerQuests:Array;
        private var m_neighbor_gate_quest_2_offset:int = 0;
        private var m_showMFI:Dictionary;
        private var m_npc_cloud_visible:Boolean = true;
        public var debugTime:Number = NAN;
        protected var m_dailyRewards:Object = null;
        protected var m_completedQuests:Array;
        public var didVisitAction:Boolean = false;

        public function Player(_arg1:SocialNetworkUser){
            this.m_licenses = new Dictionary();
            this.m_limitedItems = new Dictionary();
            this.m_neighbors = [];
            this.m_topFriends = [];
            this.m_missionItemInventory = [];
            this.m_gifts = new Object();
            this.m_promos = new Object();
            this.m_collections = {};
            this.m_completedCollections = {};
            this.m_collectionTradeIns = {};
            this.wishlist = [];
            this.m_options = {};
            this.m_flagContainer = [];
            this.m_seenFlags = {};
            this.m_seenSessionFlags = {};
            this.m_playerTimestamps = {};
            this.m_savedQuestSequence = [];
            this.m_questManagerQuests = [];
            super();
            if (_arg1){
                this.name = _arg1.name;
                this.snUser = _arg1;
            };
            this.mutualFriendsDialog = null;
            this.m_friends = new Array();
            this.m_stateObservers = new Array();
            this.m_storageComponent = new StorageComponent();
            this.m_requestInventory = new RequestInventoryComponent();
        }
        public function get dailyBonusManager():DailyBonusManager{
            return (this.m_dailyBonusManager);
        }
        override public function getSaveObject():Object{
            var _local1:Object = super.getSaveObject();
            _local1.level = this.level;
            _local1.gold = this.gold;
            _local1.cash = this.cash;
            _local1.xp = this.xp;
            _local1.neighbors = this.neighbors;
            _local1.options = this.options;
            _local1.rollCounter = this.rollCounter;
            return (_local1);
        }
        public function getStatsCounterObject():Vector.<StatsCountData>{
            var _local7:String;
            var _local8:Number;
            var _local9:Number;
            var _local1:Vector.<StatsCountData> = new Vector.<StatsCountData>();
            _local1.push(new StatsCountData(new StatsOntology("user_level"), this.level));
            _local1.push(new StatsCountData(new StatsOntology("num_coins"), this.m_gold));
            _local1.push(new StatsCountData(new StatsOntology("num_cash"), this.m_cash));
            var _local2:int = this.m_inventory.getItemCountByName("permits");
            var _local3:int = this.m_inventory.getItemCountByName("energy_1");
            var _local4:int = this.m_inventory.getItemCountByName("energy_2");
            var _local5:int = this.m_inventory.getItemCountByName("energy_3");
            _local1.push(new StatsCountData(new StatsOntology("inv_permits"), _local2));
            _local1.push(new StatsCountData(new StatsOntology("inv_energy_1"), _local3));
            _local1.push(new StatsCountData(new StatsOntology("inv_energy_2"), _local4));
            _local1.push(new StatsCountData(new StatsOntology("inv_energy_3"), _local5));
            var _local6:Array = this.m_commodities.getCommodityNames();
            for each (_local7 in _local6) {
                _local8 = this.m_commodities.getCount(_local7);
                _local9 = this.m_commodities.getCapacity(_local7);
                _local1.push(new StatsCountData(new StatsOntology(("num_" + _local7)), _local8));
                _local1.push(new StatsCountData(new StatsOntology((_local7 + "_capacity")), _local9));
                if (_local8 == 0){
                    _local1.push(new StatsCountData(new StatsOntology((_local7 + "_is_zero"))));
                };
            };
            _local1.push(new StatsCountData(new StatsOntology("num_energy"), this.m_energy));
            return (_local1);
        }
        public function setCompletedQuests(_arg1:Array):void{
            this.m_completedQuests = _arg1;
        }
        public function isQuestCompleted(_arg1:String):Boolean{
            var _local2:String;
            for each (_local2 in this.m_completedQuests) {
                if (_local2 == _arg1){
                    return (true);
                };
            };
            return (false);
        }
        public function get socialNetworkId():int{
            return (this.m_socialNetworkId);
        }
        public function set socialNetworkId(_arg1:int):void{
            this.m_socialNetworkId = _arg1;
        }
        public function get dailyRewards():Object{
            return (this.m_dailyRewards);
        }
        public function get gender():String{
            var _local1:String = (this.snUser) ? this.snUser.gender : "masc";
            _local1 = ((((_local1 == "masc")) || ((_local1 == "fem")))) ? _local1 : "masc";
            return (_local1);
        }
        override public function loadObject(_arg1:Object):void{
            var _local3:Object;
            var _local6:Object;
            var _local7:String;
            var _local8:Number;
            var _local9:XML;
            var _local10:int;
            if (_arg1.neighbor_gate_quest_2_offset){
                this.m_neighbor_gate_quest_2_offset = _arg1.neighbor_gate_quest_2_offset;
            };
            var _local2 = (Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_STARTER_PACK) > 0);
            if (((_local2) && ((_arg1.hasMadePurchase === true)))){
                this.m_hasMadePurchase = true;
            };
            this.m_seenFlags = _arg1.seenFlags;
            if (_arg1.playerNews != null){
                this.m_news = PlayerNews.loadFromObjects(_arg1.playerNews);
            };
            for each (_local3 in _arg1.flagContainer) {
                this.m_flagContainer[_local3.name] = Flag.buildFromServerObject(_local3);
            };
            this.m_inventory = new Inventory(this, _arg1.inventory);
            this.m_commodities = new Commodities(_arg1.commodities);
            this.m_requestInventory.loadObject(_arg1.requestInventory);
            this.m_storageComponent.loadObject(_arg1.storageComponent);
            this.m_dailyRewards = _arg1.dailyRewards;
            this.gold = _arg1.gold;
            this.cash = _arg1.cash;
            this.level = _arg1.level;
            this.additionalWareHouseSlots = _arg1.additionalWareHouseSlots;
            this.xp = _arg1.xp;
            this.m_energy = _arg1.energy;
            this.m_energyMax = _arg1.energyMax;
            this.m_lastEnergyCheck = _arg1.lastEnergyCheck;
            this.m_npc_cloud_visible = _arg1.npc_cloud_visible;
            if (_arg1.expansionsPurchased != null){
                this.m_expansionsPurchased = _arg1.expansionsPurchased;
            } else {
                this.m_expansionsPurchased = 0;
            };
            if (_arg1.expansionCostLevel != null){
                this.m_expansionCostLevel = _arg1.expansionCostLevel;
            } else {
                this.m_expansionCostLevel = 1;
            };
            this.m_populationObservedOnLastExpansion = (_arg1["populationObservedOnLastExpansion"]) ? _arg1["populationObservedOnLastExpansion"] : 0;
            if (_arg1.maxNeighbors != null){
                this.maxNeighbors = _arg1.maxNeighbors;
            } else {
                this.maxNeighbors = 0;
            };
            if (_arg1.franchiseUnlocksPurchased != null){
                this.franchiseUnlocksPurchased = _arg1.franchiseUnlocksPurchased;
            } else {
                this.franchiseUnlocksPurchased = 0;
            };
            if (_arg1.franchiseMoneyReturned != null){
                this.franchiseMoneyReturned = _arg1.franchiseMoneyReturned;
            } else {
                this.franchiseMoneyReturned = 0;
            };
            this.m_randomModifierGroupOverride = (_arg1.hasOwnProperty("randomModifierGroupOverride")) ? _arg1.randomModifierGroupOverride : -1;
            this.m_randomModifierOverride = (_arg1.hasOwnProperty("randomModifierOverride")) ? _arg1.randomModifierOverride : -1;
            this.options = _arg1.options;
            this.hasVisitFriend = _arg1.hasVisitFriend;
            this.m_homeIslandSize = _arg1.homeIslandSize;
            this.m_gifts = _arg1.gifts;
            this.m_randomRollCounter = _arg1.rollCounter;
            if (_arg1.rollCounterMap){
                this.m_randomRollCounterMap = new Dictionary();
                for (_local7 in _arg1.rollCounterMap) {
                    this.setRollCounterValue(_local7, _arg1.rollCounterMap[_local7]);
                };
            };
            this.m_lastWarpTime = _arg1.lastWarpTime;
            this.m_lastActionTime = _arg1.lastActionTime;
            var _local4:Array = [];
            if ((_arg1.neighbors is Array)){
                _local4 = _arg1.neighbors;
            } else {
                for each (_local8 in _arg1.neighbors) {
                    _local4.push(_local8);
                };
            };
            this.neighbors = _local4;
            if (_arg1.dailyVisits){
                this.m_dailyVisits = _arg1.daily_visits.count;
            };
            if (_arg1.compensationFlag){
                this.m_compensationFlag = _arg1.compensationFlag;
            };
            this.m_socialLevel = _arg1.socialLevel;
            this.m_socialXp = _arg1.socialXp;
            this.m_dailyBonusManager = new DailyBonusManager(_arg1);
            Global.hud.lockVisualEffectsForNextUpdate();
            this.conditionallyUpdateHUD();
            this.wishlist = _arg1.wishlist;
            if (_arg1.collections){
                this.m_collections = _arg1.collections;
            };
            if (_arg1.completedCollections){
                this.m_completedCollections = _arg1.completedCollections;
            };
            if (_arg1.collectionTradeIns){
                this.m_collectionTradeIns = _arg1.collectionTradeIns;
            };
            var _local5:XMLList = Global.gameSettings.getCollections();
            for (_local6 in _local5) {
                _local9 = _local5[_local6];
                Collection.collectInfo(_local9);
            };
            if (_arg1.topFriends){
                this.m_topFriends = _arg1.topFriends;
            };
            Global.world.citySim.neighborNavigationManager.onPlayerLoaded();
            if (_arg1.playerTimestamps){
                this.m_playerTimestamps = _arg1.playerTimestamps;
            };
            ZBarNotifier.playerInitialized = true;
            if (((_arg1.savedQuestSequence) && (_arg1.questManagerQuests))){
                _local10 = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_QUEST_MANAGER);
                if (_local10 == ExperimentDefinitions.USE_QUEST_MANAGER){
                    this.m_savedQuestSequence = _arg1.savedQuestSequence;
                    this.m_questManagerQuests = _arg1.questManagerQuests;
                };
            };
        }
        public function get lastWarpTime():int{
            return (this.m_lastWarpTime);
        }
        public function get lastActionTime():int{
            return (this.m_lastActionTime);
        }
        public function get currentTimestampEventID():String{
            return (this.m_currentTimestamp_EventID);
        }
        public function set currentTimestampEventID(_arg1:String):void{
            this.m_currentTimestamp_EventID = _arg1;
        }
        public function get previousTimestampEventID():String{
            return (this.m_previousTimestamp_EventID);
        }
        public function set previousTimestampEventID(_arg1:String):void{
            this.m_previousTimestamp_EventID = _arg1;
        }
        public function addObserver(_arg1:IPlayerStateObserver):void{
            if (!ArrayUtil.arrayContainsValue(this.m_stateObservers, _arg1)){
                this.m_stateObservers.push(_arg1);
            };
        }
        public function removeObserver(_arg1:IPlayerStateObserver):void{
            ArrayUtil.removeValueFromArray(this.m_stateObservers, _arg1);
        }
        public function getPlayerClass():Object{
            var classes:* = Global.gameSettings.getPlayerClasses();
            return (classes.(@type == this.playerClassType)[0]);
        }
        public function getPlayerNews():Array{
            return (ArrayUtil.copyArray(this.m_news));
        }
        public function getGifts():Array{
            var _local2:String;
            var _local3:String;
            var _local4:Array;
            var _local5:Item;
            var _local1:Array = new Array();
            for (_local2 in this.m_gifts) {
                _local3 = this.m_gifts[_local2];
                _local4 = _local3.split(",");
                if (((_local4[0]) && ((int(_local4[0]) > 0)))){
                    _local5 = Global.gameSettings.getItemByCode(_local2);
                    _local1.push({
                        item:_local5,
                        num:_local4[0],
                        senderArray:_local4.slice(1, _local4.length)
                    });
                };
            };
            return (_local1);
        }
        public function getGiftCount():int{
            var _local1:Array = this.getGifts();
            var _local2:int = _local1.length;
            var _local3:int;
            var _local4:int;
            while (_local4 < _local2) {
                _local3 = (_local3 + Number(_local1[_local4].num));
                _local4++;
            };
            return (_local3);
        }
        public function populatePromos(_arg1:Object):void{
            var _local2:Object = new Object();
            if (_arg1 != null){
                _local2 = _arg1;
            };
            this.m_promos = _local2;
        }
        public function set hasVisitFriend(_arg1:Number):void{
            this.m_hasVisitFriend = _arg1;
        }
        public function get hasVisitFriend():Number{
            return (this.m_hasVisitFriend);
        }
        public function get firstName():String{
            return (this.snUser.firstName);
        }
        public function set level(_arg1:int):void{
            this.conditionallyNotifyObservers(_arg1, this.m_xp, this.m_energy, this.m_gold, this.m_cash);
            this.m_level = _arg1;
            this.conditionallyUpdateHUD();
        }
        private function conditionallyNotifyObservers(_arg1:int, _arg2:int, _arg3:Number, _arg4:int, _arg5:int):void{
            var _local11:IPlayerStateObserver;
            var _local6 = !((_arg1 == this.m_level));
            var _local7 = !((_arg2 == this.m_xp));
            var _local8 = !((_arg3 == this.m_energy));
            var _local9 = !((_arg4 == this.m_gold));
            var _local10 = !((_arg5 == this.m_cash));
            this.m_level = _arg1;
            for each (_local11 in this.m_stateObservers) {
                if (_local6){
                    _local11.levelChanged(_arg1);
                };
                if (_local7){
                    _local11.xpChanged(_arg2);
                };
                if (_local8){
                    _local11.energyChanged(_arg3);
                };
                if (_local9){
                    _local11.goldChanged(_arg4);
                };
                if (_local10){
                    _local11.cashChanged(_arg5);
                };
            };
        }
        public function commodityNotifyObservers(_arg1:String):void{
            var _local2:IPlayerStateObserver;
            if (Global.player.commodities){
                for each (_local2 in this.m_stateObservers) {
                    _local2.commodityChanged(Global.player.commodities.getCount(_arg1), _arg1);
                };
            };
        }
        public function get neighbor_gate_quest_2_offset():int{
            return (this.m_neighbor_gate_quest_2_offset);
        }
        public function get level():int{
            return (this.m_level);
        }
        public function get energy():Number{
            return (this.m_energy);
        }
        public function get energyMax():Number{
            return (this.m_energyMax);
        }
        public function set energyMax(_arg1:Number):void{
            this.m_energyMax = _arg1;
            this.conditionallyUpdateHUD();
        }
        public function get expansionsPurchased():Number{
            return (this.m_expansionsPurchased);
        }
        public function set expansionsPurchased(_arg1:Number):void{
            this.m_expansionsPurchased = _arg1;
        }
        public function get expansionCostLevel():Number{
            return (this.m_expansionCostLevel);
        }
        public function set expansionCostLevel(_arg1:Number):void{
            this.m_expansionCostLevel = _arg1;
        }
        public function get maxNeighbors():int{
            return (this.m_maxNeighbors);
        }
        public function set maxNeighbors(_arg1:int):void{
            this.m_maxNeighbors = _arg1;
        }
        public function get franchiseUnlocksPurchased():int{
            return (this.m_franchiseUnlocksPurchased);
        }
        public function set franchiseUnlocksPurchased(_arg1:int):void{
            this.m_franchiseUnlocksPurchased = _arg1;
        }
        public function get franchiseMoneyReturned():int{
            return (this.m_franchiseMoneyReturned);
        }
        public function set franchiseMoneyReturned(_arg1:int):void{
            this.m_franchiseMoneyReturned = _arg1;
        }
        public function get populationObservedOnLastExpansion():int{
            return (this.m_populationObservedOnLastExpansion);
        }
        public function set populationObservedOnLastExpansion(_arg1:int):void{
            this.m_populationObservedOnLastExpansion = _arg1;
        }
        public function get lastEnergyCheck():Number{
            return (this.m_lastEnergyCheck);
        }
        public function set lastEnergyCheck(_arg1:Number):void{
            this.m_lastEnergyCheck = _arg1;
            this.conditionallyUpdateHUD();
        }
        public function setEnergyFromServer(_arg1:Number, _arg2:Number, _arg3:Number):void{
            this.conditionallyNotifyObservers(this.m_level, this.m_xp, _arg1, this.m_gold, this.m_cash);
            this.updateEnergy((_arg1 - this.energy), new Array("energy", "set_from_server", "", ""));
            this.m_energyMax = _arg2;
            this.m_lastEnergyCheck = _arg3;
            this.conditionallyUpdateHUD();
        }
        public function regenerateEnergy():void{
            if (this.energy < this.energyMax){
                this.updateEnergy(Global.gameSettings.getNumber("energyRegenerationAmount"), new Array("energy", "earnings", "time_energy", ""));
                this.lastEnergyCheck = (this.lastEnergyCheck + Global.gameSettings.getNumber("energyRegenerationSeconds"));
            };
        }
        public function get visitorEnergy():Number{
            return (this.m_visitorEnergy);
        }
        public function set visitorEnergy(_arg1:Number):void{
            this.didVisitAction = false;
            this.m_visitorEnergy = _arg1;
            this.conditionallyUpdateHUD();
        }
        public function get socialXp():Number{
            return (this.m_socialXp);
        }
        public function get socialLevel():Number{
            return (this.m_socialLevel);
        }
        public function set socialLevel(_arg1:Number):void{
            this.m_socialLevel = _arg1;
        }
        public function get dailyVisits():uint{
            return (this.m_dailyVisits);
        }
        public function set dailyVisits(_arg1:uint):void{
            this.m_dailyVisits = _arg1;
        }
        public function set xp(_arg1:int):void{
            var _local3:XMLList;
            var _local4:int;
            var _local5:Boolean;
            var _local6:int;
            var _local7:XML;
            var _local8:XML;
            var _local9:int;
            var _local10:int;
            var _local11:int;
            var _local12:int;
            if ((((_arg1 > this.m_xp)) && ((this.m_xp > 0)))){
                _local3 = Global.gameSettings.getLevelsXML().level;
                _local4 = this.level;
                if (_arg1 > 0){
                    _local5 = false;
                    _local6 = 0;
                    while (_local6 < _local3.length()) {
                        _local7 = _local3[_local6];
                        if (_arg1 >= _local7.@requiredXP){
                            _local4 = (_local6 + 1);
                            _local5 = true;
                        } else {
                            break;
                        };
                        _local6++;
                    };
                    if (((((_local5) && ((this.level < _local4)))) && ((_local4 > 1)))){
                        TransactionManager.sendAllTransactions(true);
                        UI.displayLevelUpDialog(_local4);
                        _local8 = Global.gameSettings.getLevelXML(_local4);
                        _local9 = ((_local8)!=null) ? int(_local8.@energyMax) : 0;
                        _local10 = Math.max(Global.player.energyMax, _local9);
                        Global.player.energyMax = _local10;
                        if (Global.player.energy < Global.player.energyMax){
                            _local11 = (Global.player.energy + Math.max(((Global.player.energyMax - Global.player.energy) - Global.player.heldEnergy), 0));
                            _local12 = (_local11 - Global.player.energy);
                            Global.player.updateEnergy(_local12, new Array("energy", "earnings", "level_up", _local4));
                        };
                        if (LocaleHelper.localSetting.sns.cash_enable){
                            Global.player.cash = (Global.player.cash + (Global.gameSettings.getInt("cashGainedPerLevel") * (_local4 - this.level)));
                        };
                        this.level = _local4;
                    };
                };
            };
            this.conditionallyNotifyObservers(this.m_level, _arg1, this.m_energy, this.m_gold, this.m_cash);
            var _local2:int = Global.experimentManager.getVariant("cv_display_zbar");
            if (_local2 == ExperimentDefinitions.DISPLAY_ZBAR){
                ZBarNotifier.awardXP((_arg1 - this.m_xp));
            };
            this.m_xp = _arg1;
            this.conditionallyUpdateHUD();
        }
        public function levelUpNickName(_arg1:int):String{
            var _local2:XMLList = Global.gameSettings.getLevelsXML().level;
            var _local3:XML = _local2[(this.level - 1)];
            var _local4:String = ZLoc.t("Levels", ("Level" + this.level));
            return (_local4);
        }
        public function set socialXp(_arg1:Number):void{
            var _local2:XML;
            var _local3:XMLList;
            var _local4:int;
            var _local5:Boolean;
            var _local6:int;
            var _local7:XML;
            if ((((_arg1 > this.m_socialXp)) && ((this.m_socialXp > 0)))){
                _local2 = Global.gameSettings.getXML();
                _local3 = _local2.reputation.level;
                _local4 = this.socialLevel;
                if (_arg1 > 0){
                    _local5 = false;
                    _local6 = 0;
                    while (_local6 < _local3.length()) {
                        _local7 = _local3[_local6];
                        if (_arg1 >= _local7.@requiredXP){
                            _local4 = (_local6 + 1);
                            _local5 = true;
                        } else {
                            break;
                        };
                        _local6++;
                    };
                    if (((((_local5) && ((this.socialLevel < _local4)))) && ((_local4 > 1)))){
                        TransactionManager.sendAllTransactions(true);
                        this.socialLevel = _local4;
                        UI.displaySocialLevelUpDialog(this.m_socialLevel);
                    };
                };
            };
            this.m_socialXp = _arg1;
            this.conditionallyUpdateHUD();
        }
        public function get homeIslandSize():int{
            return (this.m_homeIslandSize);
        }
        public function set homeIslandSize(_arg1:int):void{
            this.m_homeIslandSize = _arg1;
        }
        public function get xp():int{
            return (this.m_xp);
        }
        public function set gold(_arg1:int):void{
            this.conditionallyNotifyObservers(this.m_level, this.m_xp, this.m_energy, _arg1, this.m_cash);
            this.m_gold = _arg1;
            this.conditionallyUpdateHUD();
        }
        public function get gold():int{
            return (this.m_gold);
        }
        public function set cash(_arg1:int):void{
            this.conditionallyNotifyObservers(this.m_level, this.m_xp, this.m_energy, this.m_gold, _arg1);
            this.m_cash = _arg1;
            this.conditionallyUpdateHUD();
        }
        public function set energy(_arg1:Number):void{
            this.m_energy = _arg1;
            this.conditionallyNotifyObservers(this.m_level, this.m_xp, this.m_energy, this.m_gold, _arg1);
            this.conditionallyUpdateHUD();
        }
        public function get cash():int{
            return (this.m_cash);
        }
        public function get options():Object{
            return (this.m_options);
        }
        public function set options(_arg1:Object):void{
            this.m_options = _arg1;
            this.saveOptionsCookie();
            Sounds.init();
        }
        public function saveOptionsCookie():void{
            var options:* = null;
            var name:* = null;
            try {
                options = SharedObject.getLocal("options", "/");
                for (name in this.m_options) {
                    options.setProperty(name, this.m_options[name]);
                };
            } catch(e:Error) {
            };
        }
        public function addLicense(_arg1:String, _arg2:Number):void{
            this.m_licenses[_arg1] = _arg2;
        }
        public function deleteLicense(_arg1:String):void{
            delete this.m_licenses[_arg1];
        }
        public function get licenses():Dictionary{
            return (this.m_licenses);
        }
        public function getSeenFlag(_arg1:String):Boolean{
            return (this.m_seenFlags[_arg1]);
        }
        public function setSeenFlag(_arg1:String):void{
            if (this.m_seenFlags[_arg1] != true){
                GameTransactionManager.addTransaction(new TSetSeenFlag(_arg1));
                this.m_seenFlags[_arg1] = true;
            };
        }
        public function countSeenFlags(_arg1:String):int{
            var _local2:String;
            var _local3:int;
            for (_local2 in this.m_seenFlags) {
                if (_local2.search(_arg1) >= 0){
                    _local3++;
                };
            };
            for (_local2 in this.m_seenSessionFlags) {
                if (_local2.search(_arg1) >= 0){
                    _local3++;
                };
            };
            return (_local3);
        }
        public function getSeenSessionFlag(_arg1:String):Boolean{
            return (this.m_seenSessionFlags[_arg1]);
        }
        public function setSeenSessionFlag(_arg1:String):void{
            this.m_seenSessionFlags[_arg1] = true;
        }
        public function checkSeenExtendedPermissions(_arg1:String, _arg2:Boolean=true):Boolean{
            var _local3:Boolean;
            var _local4:String = ("perm_" + _arg1);
            if (!this.getSeenFlag(_local4)){
                _local3 = false;
                if (_arg2){
                    this.setSeenFlag(_local4);
                };
            };
            return (_local3);
        }
        public function numLimitedItems(_arg1:String):int{
            return (this.m_limitedItems[_arg1]);
        }
        public function hasLimitedItem(_arg1:String):Boolean{
            return (((!((this.m_limitedItems[_arg1] == undefined))) && ((this.m_limitedItems[_arg1] > 0))));
        }
        public function addLimitedItem(_arg1:String, _arg2:Boolean=true):void{
            var _local3:Array;
            var _local4:int;
            var _local5:String;
            if (this.m_limitedItems[_arg1] > 0){
                this.m_limitedItems[_arg1] = (this.m_limitedItems[_arg1] + 1);
            } else {
                this.m_limitedItems[_arg1] = 1;
            };
            if (_arg2){
                _local3 = this.getItemsFromSameLimitGroup(_arg1);
                _local4 = 0;
                while (_local4 < _local3.length) {
                    _local5 = (_local3[_local4] as String);
                    this.addLimitedItem(_local5, false);
                    _local4++;
                };
            };
        }
        public function removeLimitedItem(_arg1:String, _arg2:Boolean=true):void{
            var _local3:Array;
            var _local4:int;
            var _local5:String;
            if (((this.m_limitedItems[_arg1]) && ((this.m_limitedItems[_arg1] > 0)))){
                this.m_limitedItems[_arg1] = (this.m_limitedItems[_arg1] - 1);
                if (_arg2){
                    _local3 = this.getItemsFromSameLimitGroup(_arg1);
                    _local4 = 0;
                    while (_local4 < _local3.length) {
                        _local5 = (_local3[_local4] as String);
                        this.removeLimitedItem(_local5, false);
                        _local4++;
                    };
                };
            };
        }
        protected function getItemsFromSameLimitGroup(_arg1:String):Array{
            var _local6:XMLList;
            var _local7:Array;
            var _local8:Boolean;
            var _local9:int;
            var _local10:XML;
            var _local11:String;
            var _local2:Array = new Array();
            var _local3:XML = Global.gameSettings.getXML();
            var _local4:XMLList = _local3.limitItemOwnership.itemLimit;
            var _local5:int;
            while (_local5 < _local4.length()) {
                _local6 = _local4[_local5].item;
                _local7 = new Array();
                _local8 = false;
                _local9 = 0;
                while (_local9 < _local6.length()) {
                    _local10 = _local6[_local9];
                    _local11 = _local10.@name;
                    if (_local11 == _arg1){
                        _local8 = true;
                    } else {
                        _local7.push(_local11);
                    };
                    _local9++;
                };
                if (_local8){
                    _local2 = _local7;
                    break;
                };
                _local5++;
            };
            return (_local2);
        }
        public function checkGiftData(_arg1:Object, _arg2:String):void{
            var _local3:Item = Global.gameSettings.getItemByCode(_arg2);
            if (_local3 != null){
                Global.player.gifts[_arg2] = String(_arg1);
            };
        }
        public function set unparsedNeighborsData(_arg1:Array):void{
            this.m_unparsedNeighborsData = _arg1;
        }
        public function get unparsedNeighborsData():Array{
            return (this.m_unparsedNeighborsData);
        }
        public function set neighbors(_arg1:Array):void{
            this.m_neighbors = _arg1;
            Global.world.updateNeighborText();
            if (this.m_neighbors.length > this.m_maxNeighbors){
                this.m_maxNeighbors = this.m_neighbors.length;
            };
        }
        public function get neighbors():Array{
            var _local1:int = Global.gameSettings.getInt("maxNeighbors");
            var _local2:Array = this.m_neighbors.slice(0, _local1);
            return (_local2);
        }
        public function set topFriends(_arg1:Array):void{
            this.m_topFriends = _arg1;
        }
        public function get topFriends():Array{
            return (this.m_topFriends);
        }
        public function getPromo(_arg1:String):Object{
            var _local2:Object;
            if (((((!((_arg1 == ""))) && (this.m_promos))) && (this.m_promos[_arg1]))){
                _local2 = this.m_promos[_arg1];
            };
            return (_local2);
        }
        public function getAllPromos():Object{
            return (this.m_promos);
        }
        public function set gifts(_arg1:Object):void{
            this.m_gifts = _arg1;
        }
        public function get gifts():Object{
            return (this.m_gifts);
        }
        public function get inventory():Inventory{
            return (this.m_inventory);
        }
        public function get requestInventory():RequestInventoryComponent{
            return (this.m_requestInventory);
        }
        public function get commodities():Commodities{
            return (this.m_commodities);
        }
        public function get storageComponent():StorageComponent{
            return (this.m_storageComponent);
        }
        public function addGift(_arg1:String, _arg2:int=0, _arg3:Boolean=false):void{
            var _local4:Item = Global.gameSettings.getItemByName(_arg1);
            if ((((_local4 == null)) || (((this.checkItemLimit(_arg1)) && (!(_arg3)))))){
                return;
            };
            this.inventory.addItems(_arg1, 1, _arg3);
        }
        public function removeGift(_arg1:MapResource, _arg2:String=""):void{
            throw (new Error("Missing removeGift"));
        }
        public function hasGift(_arg1:String):Boolean{
            var _local2:Item = Global.gameSettings.getItemByName(_arg1);
            if (this.m_gifts[_local2.code] != undefined){
                return ((int(this.m_gifts[_local2.code]) > 0));
            };
            return (false);
        }
        public function removeAllGifts():void{
            this.m_gifts = new Dictionary();
            Global.world.dispatchEvent(new FarmGameWorldEvent(FarmGameWorldEvent.USER_CHANGED));
        }
        public function conditionallyUpdateHUD():void{
            if (Global.hud){
                Global.hud.gold = this.gold;
                Global.hud.cash = this.cash;
                Global.hud.xp = this.xp;
                Global.hud.energy = this.energy;
                Global.hud.updateCommodities();
                Global.hud.reputation = this.socialXp;
                Global.hud.visitEnergy = this.visitorEnergy;
                Global.hud.updateDebugText();
            };
            if (UI.m_catalog){
                UI.m_catalog.updateChangedCells();
            };
        }
        public function hasFriendsSNData():Boolean{
            return (this.m_hasFriendsSNData);
        }
        public function setFriends(_arg1:Array):void{
            var _local2:int;
            var _local3:SocialNetworkUser;
            if (_arg1 != null){
                this.m_friends = new Array();
                this.m_showMFI = new Dictionary();
                _local2 = 0;
                while (_local2 < _arg1.length) {
                    _local3 = (_arg1[_local2] as SocialNetworkUser);
                    this.m_friends.push(new Player(_local3));
                    this.m_showMFI[_local3.uid] = true;
                    _local2++;
                };
                this.m_hasFriendsSNData = true;
            };
        }
        public function get hasMadePurchase():Boolean{
            return (this.m_hasMadePurchase);
        }
        public function setFakeFriend():void{
            this.m_friends.push(this.getFakeFriend());
        }
        public function get fake():Boolean{
            return ((this.snUser.uid == FAKE_USER_ID));
        }
        public function getFakeFriend():Player{
            var _local1:Player;
            var _local2:SocialNetworkUser;
            for each (_local1 in this.m_friends) {
                if (_local1.fake){
                    return (_local1);
                };
            };
            _local2 = new SocialNetworkUser(FAKE_USER_ID);
            _local2.firstName = ZLoc.t("Main", "FakeFriendName");
            _local2.name = ZLoc.t("Main", "FakeFriendName");
            _local2.picture = Global.getAssetURL("assets/dialogs/citysam_neighbor_card.jpg");
            _local1 = new Player(_local2);
            _local1.cityName = ZLoc.t("Main", "FakeFriendCityName");
            return (_local1);
        }
        public function setFriendsNoSNData(_arg1:Array):void{
            var _local2:Number;
            var _local3:SocialNetworkUser;
            this.m_friends = new Array();
            for each (_local2 in _arg1) {
                _local3 = new SocialNetworkUser(_local2, Constants.NO_NETWORK);
                this.m_friends.push(new Player(_local3));
            };
        }
        public function get friends():Array{
            return (this.m_friends);
        }
        public function set appFriends(_arg1:Array):void{
            this.m_appFriends = _arg1;
        }
        public function get appFriends():Array{
            return (this.m_appFriends);
        }
        public function set newPlayer(_arg1:Boolean):void{
            this.m_isNew = _arg1;
        }
        public function get creationTimestamp():uint{
            return (this.m_creationTimestamp);
        }
        public function set creationTimestamp(_arg1:uint):void{
            this.m_creationTimestamp = _arg1;
        }
        public function get isNewPlayer():Boolean{
            return (this.m_isNew);
        }
        public function set firstDay(_arg1:Boolean):void{
            this.m_isFirstDay = _arg1;
        }
        public function get isFirstDay():Boolean{
            return (this.m_isFirstDay);
        }
        public function get cityName():String{
            var _local1:String;
            if (!this.m_cityName){
                _local1 = ZLoc.t("Main", "NameSuffix");
            } else {
                _local1 = this.m_cityName;
            };
            return (_local1);
        }
        public function set cityName(_arg1:String):void{
            this.m_cityName = _arg1;
        }
        public function hasSetCityName():Boolean{
            return (!((this.m_cityName == null)));
        }
        public function get pendingCityName():String{
            return (this.m_pendingCityName);
        }
        public function set pendingCityName(_arg1:String):void{
            this.m_pendingCityName = _arg1;
        }
        public function findFriendById(_arg1:String):Player{
            var _local4:Player;
            var _local2:Player;
            var _local3:int;
            while (_local3 < this.friends.length) {
                _local4 = (this.friends[_local3] as Player);
                if (_local4.uid == _arg1){
                    _local2 = _local4;
                    break;
                };
                _local3++;
            };
            return (_local2);
        }
        public function isFriendIDInList(_arg1:String):Boolean{
            var _local3:Player;
            var _local2:int;
            while (_local2 < this.friends.length) {
                _local3 = (this.friends[_local2] as Player);
                if (_local3.uid == _arg1){
                    return (true);
                };
                _local2++;
            };
            return (false);
        }
        public function isFriendANeighbor(_arg1:String):Boolean{
            var _local2:String;
            for each (_local2 in this.neighbors) {
                if (_local2 == _arg1){
                    return (true);
                };
            };
            return (false);
        }
        public function getFriendName(_arg1:String):String{
            var _local2:String;
            var _local3:Player = this.findFriendById(_arg1);
            if (_local3){
                _local2 = _local3.name;
            };
            return (_local2);
        }
        public function getFriendFirstName(_arg1:String):String{
            var _local2:String;
            var _local3:Player = this.findFriendById(_arg1);
            if (_local3){
                _local2 = _local3.firstName;
            };
            return (_local2);
        }
        public function setFriendCityName(_arg1:String, _arg2:String):void{
            var _local3:String;
            var _local4:Player = this.findFriendById(_arg1);
            if (_local4){
                _local4.cityName = _arg2;
            };
        }
        public function getFriendCityName(_arg1:String):String{
            var _local2:String;
            var _local3:Player = this.findFriendById(_arg1);
            if (_arg1 == "-1"){
                return (ZLoc.t("Main", "FakeFriendCityName"));
            };
            if (_local3){
                _local2 = _local3.cityName;
            };
            var _local4:Boolean;
            if (_local2 == null){
                _local4 = true;
            } else {
                if (_local2.length == 0){
                    _local4 = true;
                };
            };
            if (_local4){
                if (_local3){
                    _local2 = ZLoc.t("Main", "FriendNameSuffix", {name:ZLoc.tn(_local3.firstName)});
                } else {
                    _local2 = ZLoc.t("Main", "NameSuffix");
                };
            };
            return (_local2);
        }
        public function canBuy(_arg1:int, _arg2:Boolean=true):Boolean{
            var _local3 = (this.gold >= _arg1);
            if (((!(_local3)) && (_arg2))){
                UI.flushDialogs();
                UI.displayImpulseBuyPopup(ImpulseBuy.TYPE_MARKET_COINS);
            };
            return (_local3);
        }
        public function canBuyCash(_arg1:int, _arg2:Boolean=true):Boolean{
            var _local3 = ((this.cash - _arg1) >= 0);
            if (((!(_local3)) && (_arg2))){
                UI.flushDialogs();
                UI.displayImpulseBuyPopup(ImpulseBuy.TYPE_MARKET_CASH);
            };
            return (_local3);
        }
        public function canBuyCommoditiy(_arg1:int, _arg2:String, _arg3:Boolean=true):Boolean{
            var _local4 = (Global.player.commodities.getCount(_arg2) >= _arg1);
            if (((!(_local4)) && (_arg3))){
                UI.flushDialogs();
                UI.displayImpulseBuyPopup(ImpulseBuy.TYPE_MARKET_COMMODITY);
            };
            return (_local4);
        }
        public function tryBuy(_arg1:MapResource, _arg2:Boolean=false, _arg3:Item=null):Boolean{
            var _local5:Item;
            var _local9:int;
            var _local10:int;
            var _local4:Boolean;
            _local5 = _arg3;
            if (_local5 == null){
                _local5 = _arg1.getItem();
            };
            switch (_local5.market){
                case Market.COST_CASH:
                    _local9 = _local5.cash;
                    _local4 = Global.player.canBuyCash(_local9, (_arg2 == false));
                    break;
                case Market.COST_COINS:
                default:
                    _local10 = _local5.cost;
                    _local4 = Global.player.canBuy(_local10, (_arg2 == false));
            };
            var _local6:int = _local5.cost;
            var _local7:Number = Math.floor((_local6 * Global.gameSettings.getNumber("buyXpGainRatio")));
            var _local8:Number = Math.max(_local7, Global.gameSettings.getNumber("buyXpGainMin"));
            Global.player.xp = (Global.player.xp + _local8);
            if (_local9){
                Global.player.cash = (Global.player.cash - _local9);
                if (_arg1 != null){
                    _arg1.displayStatus(ZLoc.t("Main", "Status_BuyCash", {
                        cash:_local9,
                        experience:_local8
                    }));
                };
            } else {
                if (_local10){
                    Global.player.gold = (Global.player.gold - _local10);
                    if (_arg1 != null){
                        _arg1.displayStatus(ZLoc.t("Main", "Status_BuyObject", {
                            coins:_local10,
                            experience:_local8
                        }));
                    };
                };
            };
            return (_local4);
        }
        public function checkLevel(_arg1:int):Boolean{
            return ((this.level >= _arg1));
        }
        public function checkNeighbors(_arg1:int):Boolean{
            return ((this.maxNeighbors >= _arg1));
        }
        public function checkPopulation(_arg1:int):Boolean{
            return ((Global.world.citySim.getPopulation() >= _arg1));
        }
        public function checkItemLimit(_arg1:String):Boolean{
            return ((this.inventory.spareCapacity <= 0));
        }
        public function checkGate(_arg1:String, _arg2:String):Boolean{
            var _local6:Boolean;
            var _local7:Boolean;
            var _local8:Boolean;
            var _local9:Boolean;
            var _local10:Boolean;
            var _local3:Boolean;
            var _local4:Item = Global.gameSettings.getItemByName(_arg2);
            var _local5:XML = ((_local4)!=null) ? _local4.xml : null;
            if (_local5){
                _local6 = this.checkLevel(_local5.requiredLevel);
                _local7 = this.checkNeighbors(_local5.minNeighbors);
                _local8 = ExpansionManager.instance.hasPassedExpansionGate();
                _local9 = Global.questManager.isFlagReached(_local4.requiredQuestFlag);
                _local10 = this.checkPopulation(_local4.requiredPopulation);
                switch (_arg1){
                    case Item.UNLOCK_LOCKED:
                        _local3 = false;
                        break;
                    case Item.UNLOCK_LEVEL:
                        _local3 = _local6;
                        break;
                    case Item.UNLOCK_NEIGHBOR:
                        _local3 = _local7;
                        break;
                    case Item.UNLOCK_PERMITS:
                        if (_local4.requiredQuestFlag.length > 0){
                            _local3 = ((_local8) && (_local9));
                        } else {
                            _local3 = _local8;
                        };
                        break;
                    case Item.UNLOCK_QUEST_FLAG:
                    case Item.UNLOCK_OLD_QUEST_OR_PURCHASE:
                        _local3 = _local9;
                        break;
                    case Item.UNLOCK_POPULATION:
                        _local3 = _local10;
                        break;
                    case Item.UNLOCK_QUEST_AND_LEVEL:
                        _local3 = ((_local9) && (_local6));
                        break;
                    case Item.UNLOCK_QUEST_AND_NEIGHBOR:
                        _local3 = ((_local9) && (_local7));
                        break;
                    default:
                        _local3 = _local6;
                };
            };
            if (this.m_licenses[_arg2] == 1){
                _local3 = true;
            };
            return (_local3);
        }
        public function updateEnergy(_arg1:int, _arg2:Array):Boolean{
            var _local3:int;
            var _local4:String;
            var _local5:Array;
            if (this.checkEnergy(_arg1)){
                _local3 = this.m_energy;
                this.conditionallyNotifyObservers(this.m_level, this.m_xp, (this.m_energy + _arg1), this.m_gold, this.m_cash);
                if ((((this.m_energy >= this.m_energyMax)) && ((_arg1 < 0)))){
                    this.m_lastEnergyCheck = int((GlobalEngine.getTimer() / 1000));
                };
                this.m_energy = Math.max((this.m_energy + _arg1), 0);
                this.conditionallyUpdateHUD();
                if ((((this.m_energy <= 1)) && ((_local3 > this.m_energy)))){
                    GameTransactionManager.addTransaction(new TUpdateEnergy(), true);
                };
                _local4 = GlobalEngine.socialNetwork.getLoggedInUserId();
                _local5 = RuntimeVariableManager.getString("ENERGY_TRACKING_WHITELIST", "").split(",");
                if (((!((_local5 == null))) && ((_local5.indexOf(_local4) >= 0)))){
                    if (_arg2 == null){
                        _arg2 = new Array("energy", "no_tracking_info", "", "");
                    };
                    StatsManager.count((_arg2[0] + "_client"), _arg2[1], _arg2[2], _arg2[3], this.energy.toString(), _arg1.toString());
                };
                return (true);
            };
            return (false);
        }
        public function checkEnergy(_arg1:int, _arg2:Boolean=true):Boolean{
            var _local3:int = (this.m_energy + _arg1);
            if (_arg2){
                this.energyChangeHandler(_local3, this.m_energy);
            };
            if (_local3 >= 0){
                return (true);
            };
            return (false);
        }
        private function energyChangeHandler(_arg1:int, _arg2:int):void{
            if ((((_arg1 <= 0)) && (!(this.m_handlingOutOfEnergy)))){
                this.handleOutOfEnergy(_arg1, _arg2);
            };
        }
        public function isNewEnergyAtMaxCapacity(_arg1:int):Boolean{
            var _local2:int = Global.gameSettings.getInt("energyCap");
            if (this.m_energy < (_local2 + this.m_energyMax)){
                return (false);
            };
            return (true);
        }
        public function returnNewEnergyInCaseOfOverflow(_arg1:int):int{
            var _local2:int = Global.gameSettings.getInt("energyCap");
            if (this.m_energy < (_local2 + this.m_energyMax)){
                return ((_local2 + this.m_energyMax));
            };
            return (-1);
        }
        public function checkForEnergyOverflow(_arg1:int):Boolean{
            var _local2:int = Global.gameSettings.getInt("energyCap");
            if ((((_arg1 > (this.m_energyMax + _local2))) && (!(this.m_handlingOutOfEnergy)))){
                return (true);
            };
            return (false);
        }
        private function energyOverflowHandler(_arg1:int, _arg2:int):void{
            if (!this.checkForEnergyOverflow(_arg1)){
                return;
            };
            if ((((((Global.player.returnNewEnergyInCaseOfOverflow(_arg1) == -1)) && (!(this.m_handlingOutOfEnergy)))) && ((_arg1 > _arg2)))){
                this.showEnergyCanNotBeAddedDialog();
                return;
            };
            if (((!(this.m_handlingOutOfEnergy)) && ((_arg1 > _arg2)))){
                this.showEnergyIsNowFull();
            };
        }
        public function showEnergyCanNotBeAddedDialog():void{
            var _local2:String;
            var _local3:GenericDialog;
            var _local1 = "EnergyOverflow";
            _local2 = ZLoc.t("Dialogs", "EnergyOverflowWasFull");
            _local3 = new EnergyDialog(_local2, _local1, GenericDialogView.TYPE_OK, null, _local1, null, true, 0, "Okay");
            Global.ui.delayPopup(this.ENERGY_OVERFLOW_POPUP_DELAY, _local3, true, "energyOverflow", true);
        }
        public function showEnergyIsNowFull():void{
            var _local2:String;
            var _local3:GenericDialog;
            var _local1 = "EnergyOverflow";
            _local2 = ZLoc.t("Dialogs", "EnergyOverflowNowFull");
            _local3 = new EnergyDialog(_local2, _local1, GenericDialogView.TYPE_OK, null, _local1, null, true, 0, "Okay");
            Global.ui.delayPopup(this.ENERGY_OVERFLOW_POPUP_DELAY, _local3, true, "energyOverflow", true);
        }
        private function showNewUserOutOfEnergyPrompt():void{
            var _local2:String;
            var _local3:GenericDialog;
            if (!LocaleHelper.localSetting.sns.cash_enable){
                return;
            };
            var _local1 = "NewUserOutOfEnergy";
            _local2 = ZLoc.t("Dialogs", "NewUserOutOfEnergyMessage");
            _local3 = new EnergyDialog(_local2, _local1, GenericDialogView.TYPE_OK, this.outOfEnergyShowMarket, _local1, null, true, 0, "GetEnergy");
            Global.ui.delayPopup(this.OUT_OF_ENERGY_POPUP_DELAY, _local3, true, "newUserOutOfEnergy", true);
        }
        protected function handleOutOfEnergy(_arg1:int, _arg2:int):void{
            var _local3:GenericDialog;
            var _local5:String;
            var _local6:String;
            var _local7:String;
            var _local8:GenericDialog;
            if (_arg1 < 0){
                if (!LocaleHelper.localSetting.sns.cash_enable){
                    return;
                };
                this.outOfEnergyForceShowMarket(null);
                return;
            };
            if (_arg1 != 0){
                return;
            };
            this.m_handlingOutOfEnergy = true;
            if (this.m_isNew){
                this.showNewUserOutOfEnergyPrompt();
                return;
            };
            if (this.OOE_Coin == -1){
                this.OOE_Coin = Math.floor((Math.random() * 2));
                if (this.OOE_Coin == this.COINFLIP_FEED){
                    this.m_doOutOfEnergyFeed = false;
                    this.m_doOutOfEnergyRequest = true;
                } else {
                    this.m_doOutOfEnergyFeed = true;
                    this.m_doOutOfEnergyRequest = false;
                };
            };
            var _local4:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_OUTOFENERGY_COMBO);
            if (_local4 == 1){
                if (this.m_doOutOfEnergyFeed){
                    _local3 = new ComboEnergyDialog(this.outOfEnergyForceShowMarket, this.postOutOfEnergyFeed);
                } else {
                    _local3 = new ComboEnergyDialog(this.outOfEnergyForceShowMarket, this.sendOutOfEnergyRequest);
                };
            } else {
                if (_local4 == 0){
                    this.m_outOfEnergyCount++;
                    if (this.m_outOfEnergyCount == 2){
                        if (this.m_dailyVisits < this.m_socialLevel){
                            _local5 = "OutOfEnergy";
                            _local6 = ZLoc.t("Dialogs", "OutOfEnergyVisitNeighborsMessage");
                            _local8 = new GenericDialog(_local6, _local5, GenericDialogView.TYPE_OK, this.outOfEnergyNeighborVisit, _local5, "assets/rewards/reward_energy.png");
                            Global.ui.delayPopup(this.OUT_OF_ENERGY_POPUP_DELAY, _local8, true, "visitPrompt", true);
                            return;
                        };
                    };
                    _local5 = "OutOfEnergy";
                    _local7 = "assets/rewards/reward_energy.png";
                    if (this.m_doOutOfEnergyFeed){
                        StatsManager.count(StatsCounterType.PROMPTS, StatsKingdomType.OUT_OF_ENERGY, StatsPhylumType.ENERGY_COMBO_DISABLED, "feed_prompted");
                        _local6 = ZLoc.t("Dialogs", "OutOfEnergyFeedMessage");
                        _local3 = new GenericDialog(_local6, _local5, GenericDialogView.TYPE_ASKFRIEND, this.postOutOfEnergyFeed, _local5, _local7, true);
                    } else {
                        StatsManager.count(StatsCounterType.PROMPTS, StatsKingdomType.OUT_OF_ENERGY, StatsPhylumType.ENERGY_COMBO_DISABLED, "request_prompted");
                        _local6 = ZLoc.t("Dialogs", "OutOfEnergyRequestMessage");
                        _local3 = new GenericDialog(_local6, _local5, GenericDialogView.TYPE_ASKFRIEND, this.sendOutOfEnergyRequest, _local5, _local7, true);
                    };
                };
            };
            this.m_doOutOfEnergyFeed = !(this.m_doOutOfEnergyFeed);
            this.m_doOutOfEnergyRequest = !(this.m_doOutOfEnergyRequest);
            Global.ui.delayPopup(this.OUT_OF_ENERGY_POPUP_DELAY, _local3, true, "outOfEnergy", true);
        }
        private function outOfEnergyShowMarket(_arg1:GenericPopupEvent):void{
            if (!LocaleHelper.localSetting.sns.cash_enable){
                return;
            };
            StatsManager.count(StatsCounterType.PROMPTS, StatsKingdomType.OUT_OF_ENERGY, StatsPhylumType.ENERGY_COMBO_DISABLED, "buy_prompted");
            if (((_arg1) && ((_arg1.button == GenericDialogView.YES)))){
                StatsManager.count(StatsCounterType.PROMPTS, StatsKingdomType.OUT_OF_ENERGY, StatsPhylumType.ENERGY_COMBO_DISABLED, "buy_accepted");
                UI.displayCatalog("extras", "energy_2", false, "", false, false, true);
            };
            this.m_handlingOutOfEnergy = false;
        }
        private function outOfEnergyForceShowMarket(_arg1:GenericPopupEvent):void{
            if (!LocaleHelper.localSetting.sns.cash_enable){
                return;
            };
            UI.displayCatalog("extras", "energy_2", false, "", false, false, true);
            this.m_handlingOutOfEnergy = false;
        }
        private function postOutOfEnergyFeed(_arg1:GenericPopupEvent):void{
            if ((((_arg1.button == GenericDialogView.YES)) || ((_arg1.button == GenericDialogView.YES_NOMARKET)))){
                if (_arg1.button == GenericDialogView.YES){
                    StatsManager.count(StatsCounterType.PROMPTS, StatsKingdomType.OUT_OF_ENERGY, StatsPhylumType.ENERGY_COMBO_DISABLED, "feed_posted");
                };
                Global.world.viralMgr.sendEnergyFeed(Global.player);
                this.m_handlingOutOfEnergy = false;
            };
            if (_arg1.button != GenericDialogView.YES_NOMARKET){
                this.buyEnergyInMarket();
            };
        }
        private function sendOutOfEnergyRequest(_arg1:GenericPopupEvent):void{
            if (((((_arg1) && ((_arg1.button == GenericDialogView.YES)))) || ((_arg1.button == GenericDialogView.YES_NOMARKET)))){
                if (_arg1.button == GenericDialogView.YES){
                    StatsManager.count(StatsCounterType.PROMPTS, StatsKingdomType.OUT_OF_ENERGY, StatsPhylumType.ENERGY_COMBO_DISABLED, "request_posted");
                };
                Global.world.viralMgr.sendEnergyRequest();
                this.m_handlingOutOfEnergy = false;
            };
            if (_arg1.button != GenericDialogView.YES_NOMARKET){
                this.buyEnergyInMarket();
            };
        }
        private function outOfEnergyNeighborVisit(_arg1:GenericPopupEvent):void{
            if (((_arg1) && (!((_arg1.button == GenericDialogView.YES))))){
                this.buyEnergyInMarket();
            };
            this.m_handlingOutOfEnergy = false;
        }
        public function buyEnergyInMarket():void{
            var _local1:String;
            var _local2:String;
            var _local3:EnergyDialog;
            if (!LocaleHelper.localSetting.sns.cash_enable){
                return;
            };
            if (this.m_energy == 0){
                _local1 = "OutOfEnergyVisitMarket";
                _local2 = ZLoc.t("Dialogs", "OutOfEnergyVisitMarketMessage");
                _local3 = new EnergyDialog(_local2, _local1, GenericDialogView.TYPE_OK, this.outOfEnergyShowMarket, _local1, null, true, 0, "GetEnergy");
                UI.displayPopup(_local3, true, "visitMarketPrompt", true);
            } else {
                this.m_handlingOutOfEnergy = false;
            };
        }
        public function useVisitorEnergy(_arg1:uint):Boolean{
            if (this.checkVisitorEnergy(_arg1)){
                this.m_visitorEnergy = (this.m_visitorEnergy - _arg1);
                this.conditionallyUpdateHUD();
                this.checkIfNeedToTriggerVisitFeeds();
                this.didVisitAction = true;
                return (true);
            };
            return (false);
        }
        public function isVisitorEnergyZero():Boolean{
            return ((this.m_visitorEnergy == 0));
        }
        public function checkIfNeedToTriggerVisitFeeds():void{
            var _local1:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_MFI);
            if ((((this.m_visitorEnergy == 4)) && ((this.mutualFriendsDialog == null)))){
                if (_local1 == 1){
                    GameTransactionManager.addTransaction(new TRequestMutualFriends(Global.world.ownerId, false), true);
                };
            } else {
                if (this.isVisitorEnergyZero()){
                    NeighborVisitManager.sendRTNeighborVisitMessage();
                    if (_local1 == 1){
                        if (this.mutualFriendsDialog == null){
                            GameTransactionManager.addTransaction(new TRequestMutualFriends(Global.world.ownerId, true), true);
                            this.mutualFriendsDialog = null;
                        } else {
                            UI.displayPopup(this.mutualFriendsDialog);
                            this.mutualFriendsDialog = null;
                        };
                        StatsManager.sample(10, StatsCounterType.PROMPTS, StatsKingdomType.MFI);
                    } else {
                        NeighborVisitManager.triggerNeighborVisitFeeds();
                    };
                };
            };
        }
        public function checkVisitorEnergy(_arg1:uint):Boolean{
            return ((this.m_visitorEnergy >= _arg1));
        }
        public function get uid():String{
            return (this.snUser.uid);
        }
        public function giveRewards(_arg1:Object, _arg2:Boolean=false):void{
            var _local3:String;
            var _local4:Vector.<FranchiseExpansionData>;
            var _local5:FranchiseExpansionData;
            var _local6:String;
            for (_local3 in _arg1) {
                switch (_local3){
                    case "gold":
                    case "coins":
                        this.gold = (this.gold + int(_arg1[_local3]));
                        break;
                    case "cash":
                        this.cash = (this.cash + int(_arg1[_local3]));
                        break;
                    case "xp":
                        this.xp = (this.xp + int(_arg1[_local3]));
                        break;
                    case "energy":
                        Global.player.updateEnergy(int(_arg1[_local3]), new Array("energy", "earnings", "quest_drop", ""));
                        break;
                    case "goods":
                        this.commodities.add("goods", int(_arg1[_local3]));
                        break;
                    case "itemName":
                    case "item":
                        this.addGift(_arg1[_local3], 0, _arg2);
                        break;
                    case "itemUnlock":
                        this.setSeenSessionFlag(String(_arg1[_local3]));
                        this.conditionallyUpdateHUD();
                        break;
                    case "grantHQ":
                        if (String((_arg1[_local3] == "true"))){
                            _local4 = Global.franchiseManager.model.getFranchisesByLocation(Player.FAKE_USER_ID_STRING);
                            for each (_local5 in _local4) {
                                _local6 = Global.franchiseManager.model.getHeadquartersType(_local5.franchiseType);
                                Global.franchiseManager.grantHeadquarters(_local6, false);
                            };
                        };
                        break;
                };
            };
        }
        public function update():void{
            Global.hud.conditionallyRefreshHUD();
        }
        public function GetDooberMinimums(_arg1:Item, _arg2:String, _arg3:String=null):Number{
            var modifier:* = null;
            var modifierTable:* = null;
            var multis:* = null;
            var tableMultiplier:* = NaN;
            var roll:* = null;
            var rollTotal:* = NaN;
            var gotTotal:* = false;
            var dooberXML:* = null;
            var dooberName:* = null;
            var dooberAmount:* = NaN;
            var item:* = _arg1;
            var type:* = _arg2;
            var modifiersName = _arg3;
            var randomModifiersXml:* = item.randomModifiersXml;
            if (modifiersName){
                randomModifiersXml = item.getRandomModifiersXmlByName(modifiersName);
            };
            var strCheckType:* = type;
            if (randomModifiersXml == null){
                return (-1);
            };
            if ((((type == Doober.DOOBER_COLLECTABLE)) || ((type == Doober.DOOBER_REP)))){
                return (-1);
            };
            var modifierTables:* = Global.gameSettings.getRandomModifierTables();
            var randomModifiers:* = randomModifiersXml;
            var returnValue:* = -1;
            var found:* = false;
            for each (modifier in randomModifiersXml.modifier) {
                modifierTable = modifierTables.randomModifierTable.(@name == modifier.@tableName);
                if (!modifierTable[0]){
                } else {
                    multis = (modifier.@multiplier as XMLList);
                    tableMultiplier = (((!((multis == null))) && ((multis.length() > 0)))) ? Number(multis) : 1;
                    for each (roll in modifierTable[0].roll) {
                        rollTotal = 0;
                        gotTotal = false;
                        for each (dooberXML in roll.children()) {
                            dooberName = dooberXML.localName();
                            dooberAmount = Number(parseFloat(dooberXML.@amount));
                            if (dooberName == Doober.DOOBER_ITEM){
                                dooberAmount = 1;
                            };
                            if (dooberName == strCheckType){
                                rollTotal = (rollTotal + dooberAmount);
                                gotTotal = true;
                            };
                        };
                        if (!gotTotal){
                        } else {
                            rollTotal = (rollTotal * tableMultiplier);
                            if (!found){
                                returnValue = rollTotal;
                                found = true;
                            } else {
                                returnValue = Math.min(returnValue, rollTotal);
                            };
                        };
                    };
                };
            };
            return (returnValue);
        }
        public function processRandomModifiers(_arg1:Item, _arg2:MapResource, _arg3:Boolean, _arg4:Array, _arg5:String="default", _arg6:String=null):Array{
            var _local11:Number;
            var _local12:Number;
            var _local13:Number;
            var _local14:Number;
            var _local15:XMLList;
            var _local7:XML;
            var _local8:Array;
            var _local9:Array;
            if (_arg5 != ""){
                if (((_arg3) && (!((_arg2 == null))))){
                    _local11 = ItemBonus.getBonusModifier(_arg2, ItemBonus.XP_YIELD);
                    _local12 = ItemBonus.getBonusModifier(_arg2, ItemBonus.COIN_YIELD);
                    _local13 = ItemBonus.getBonusModifier(_arg2, ItemBonus.GOODS_YIELD);
                    _local14 = ItemBonus.getBonusModifier(_arg2, ItemBonus.PREMIUM_GOODS_YIELD);
                    _local8 = [Doober.DOOBER_COIN, Doober.DOOBER_XP, Doober.DOOBER_GOODS, Doober.DOOBER_PREMIUM_GOODS];
                    _local9 = [_local12, _local11, _local13, _local14];
                };
                if (((!((_arg1.randomModifierGroupsXml == null))) && ((_arg1.randomModifierGroupsXml.length() > 0)))){
                    _local15 = _arg1.randomModifierGroupsXml;
                    _local7 = this.chooseRandomModifiersXml(_arg1, _local15, _arg5, _arg4);
                };
                if ((((_local7 == null)) && (!((_arg1.randomModifiersXml == null))))){
                    _local7 = _arg1.randomModifiersXml;
                };
            };
            if (_arg6){
                _local7 = _arg1.getRandomModifiersXmlByName(_arg6);
            };
            var _local10:Array = new Array();
            if (_local7){
                _local10 = this.processRandomModifiersFromConfig(_local7, _arg1, _arg4, _local8, _local9, _arg2);
            };
            return (_local10);
        }
        private function chooseRandomModifiersXml(_arg1:Item, _arg2:XMLList, _arg3:String, _arg4:Array):XML{
            var rollRange:* = 0;
            var debugName:* = null;
            var secureRand:* = 0;
            var runningTotalPercent:* = NaN;
            var modifiersName:* = null;
            var modifiers:* = null;
            var randMods:* = null;
            var rollPercent:* = NaN;
            var item:* = _arg1;
            var randomModifierGroups:* = _arg2;
            var randomModifierGroupName:* = _arg3;
            var secureRandsOut:* = _arg4;
            var randomConfigGroup:* = randomModifierGroups.(@name == randomModifierGroupName)[0];
            rollRange = 99;
            if (!randomConfigGroup){
                return (null);
            };
            debugName = (item.name + (Global.isVisiting()) ? "/visit" : "");
            secureRand = SecureRand.rand(0, rollRange, debugName);
            secureRandsOut.push(secureRand);
            if (this.m_randomModifierGroupOverride > -1){
                secureRand = this.m_randomModifierGroupOverride;
            };
            runningTotalPercent = 0;
            modifiersName = "";
            for each (modifiers in randomConfigGroup.modifiers) {
                rollPercent = parseFloat(modifiers.@percent);
                runningTotalPercent = (runningTotalPercent + rollPercent);
                if (secureRand < runningTotalPercent){
                    modifiersName = modifiers.@name;
                    break;
                };
            };
            randMods = item.randomModifiersXmlList;
            if ((((randMods.length() > 0)) && (randMods.hasOwnProperty("@name")))){
                return (randMods.(@name == modifiersName)[0]);
            };
            return (null);
        }
        private function processRandomModifiersFromConfig(_arg1:XML, _arg2:Item, _arg3:Array, _arg4:Array, _arg5:Array, _arg6:MapResource):Array{
            var modifier:* = null;
            var debugName:* = null;
            var secureRand:* = 0;
            var multiplier:* = NaN;
            var modifierTable:* = null;
            var found:* = false;
            var prevRollPercent:* = NaN;
            var rollPercent:* = NaN;
            var roll:* = null;
            var curveO:* = null;
            var sourceO:* = null;
            var val:* = 0;
            var classRef:* = null;
            var functionRef:* = null;
            var dooberXML:* = null;
            var dooberName:* = null;
            var dooberAmount:* = NaN;
            var curveI:* = null;
            var sourceI:* = null;
            var valI:* = 0;
            var classRefI:* = null;
            var functionRefI:* = null;
            var ndx:* = 0;
            var dooberMultiplier:* = NaN;
            var isValidDoober:* = false;
            var variant:* = 0;
            var maxPopIncrease:* = 0;
            var basePop:* = 0;
            var populationIncrease:* = 0;
            var dropTable:* = null;
            var varStr:* = null;
            var itemDefinition:* = null;
            var drop:* = null;
            var randomModifiers:* = _arg1;
            var item:* = _arg2;
            var secureRandsOut:* = _arg3;
            var typesOfDoobersToModify:* = _arg4;
            var dooberModifiers:* = _arg5;
            var object:* = _arg6;
            var modifierTables:* = Global.gameSettings.getRandomModifierTables();
            var rollRange:* = 99;
            var doobersArray:* = new Array();
            for each (modifier in randomModifiers.modifier) {
                debugName = (item.name + (Global.isVisiting()) ? "/visit" : "");
                secureRand = SecureRand.rand(0, rollRange, debugName);
                secureRandsOut.push(secureRand);
                multiplier = 1;
                if (modifier.hasOwnProperty("@multiplier")){
                    multiplier = Number(modifier.@multiplier);
                };
                if (this.m_randomModifierOverride > -1){
                    secureRand = this.m_randomModifierOverride;
                };
                modifierTable = modifierTables.randomModifierTable.(@name == modifier.@tableName);
                if (!modifierTable[0]){
                } else {
                    found = false;
                    prevRollPercent = 0;
                    rollPercent = 0;
                    for each (roll in modifierTable[0].roll) {
                        if (roll.@percent){
                            if ((((((((roll.attribute("curve").length() > 0)) && ((roll.attribute("source").length() > 0)))) && (!((object == null))))) && (!((object is ConstructionSite))))){
                                curveO = roll.attribute("curve").toString();
                                sourceO = roll.attribute("source").toString();
                                val = object[sourceO]();
                                classRef = (AlgebraicCurveManager as Class);
                                functionRef = (classRef[curveO] as Function);
                                if (functionRef != null){
                                    rollPercent = (functionRef(val) + prevRollPercent);
                                };
                            } else {
                                rollPercent = (parseFloat(roll.@percent) + prevRollPercent);
                            };
                            prevRollPercent = rollPercent;
                            if ((((secureRand < rollPercent)) && (!(found)))){
                                for each (dooberXML in roll.children()) {
                                    dooberName = dooberXML.localName();
                                    dooberAmount = Number(parseFloat(dooberXML.@amount));
                                    if ((((((((dooberXML.attribute("curve").length() > 0)) && ((dooberXML.attribute("source").length() > 0)))) && (!((object == null))))) && (!((object is ConstructionSite))))){
                                        curveI = dooberXML.attribute("curve").toString();
                                        sourceI = dooberXML.attribute("source").toString();
                                        valI = object[sourceI]();
                                        classRefI = (AlgebraicCurveManager as Class);
                                        functionRefI = (classRefI[curveI] as Function);
                                        if (functionRefI != null){
                                            dooberAmount = functionRefI(valI);
                                        };
                                    };
                                    if (typesOfDoobersToModify != null){
                                        ndx = typesOfDoobersToModify.indexOf(dooberName);
                                        dooberMultiplier = 1;
                                        if ((((ndx >= 0)) && ((ndx < dooberModifiers.length)))){
                                            dooberMultiplier = dooberModifiers[ndx];
                                            dooberAmount = (dooberMultiplier * dooberAmount);
                                        };
                                    };
                                    if (((!((dooberName == Doober.DOOBER_COLLECTABLE))) || ((((dooberName == Doober.DOOBER_COLLECTABLE)) && (!(Global.guide.isActive())))))){
                                        isValidDoober = false;
                                        switch (dooberName){
                                            case Doober.DOOBER_COLLECTABLE:
                                                dooberName = dooberXML.@name;
                                                dooberAmount = 1;
                                                isValidDoober = true;
                                                break;
                                            case Doober.DOOBER_POPULATION:
                                                variant = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_BABY_DOOBERS_DROP);
                                                if (variant != dooberAmount){
                                                    isValidDoober = false;
                                                    break;
                                                };
                                                maxPopIncrease = (Global.world.citySim.getPopulationCap() - Global.world.citySim.getPopulation());
                                                if ((item.populationMax - object.getPopulationYield()) < maxPopIncrease){
                                                    maxPopIncrease = (item.populationMax - object.getPopulationYield());
                                                };
                                                if (maxPopIncrease < 1){
                                                    isValidDoober = false;
                                                    break;
                                                };
                                                if (Global.world.citySim.getHappinessState() == CitySim.HAPPINESS_BAD){
                                                    isValidDoober = false;
                                                    break;
                                                };
                                                basePop = item.populationBase;
                                                dooberAmount = 0;
                                                populationIncrease = 0;
                                                dropTable = Global.gameSettings.getXML().populationDropTable[0];
                                                for each (drop in dropTable.children()) {
                                                    if (basePop > parseInt(drop.@populationBase)){
                                                        populationIncrease = drop.@drop;
                                                        if (populationIncrease > maxPopIncrease){
                                                            populationIncrease = maxPopIncrease;
                                                            break;
                                                        };
                                                        dooberAmount = (dooberAmount + 1);
                                                    } else {
                                                        break;
                                                    };
                                                };
                                                varStr = ("variant=" + variant);
                                                StatsManager.sample(10, "doobers", "doober_creation", "client", Doober.DOOBER_POPULATION, populationIncrease.toString(), varStr);
                                                object.addPopulation(populationIncrease);
                                                Global.world.citySim.recomputePopulation(Global.world, false);
                                                dooberName = Global.gameSettings.getDooberFromType(dooberName, dooberAmount);
                                                dooberAmount = populationIncrease;
                                                isValidDoober = true;
                                                break;
                                            case Doober.DOOBER_ITEM:
                                                dooberName = dooberXML.@name;
                                                dooberAmount = 1;
                                                itemDefinition = Global.gameSettings.getItemByName(dooberName);
                                                if (((itemDefinition) && (itemDefinition.getImageByName("initial")))){
                                                    isValidDoober = true;
                                                } else {
                                                    HolidayTree.showUniquePresentDialog(dooberName);
                                                    this.inventory.addItems(dooberName, 1);
                                                    StatsManager.sample(100, StatsKingdomType.GAME_ACTIONS, "event", "reward", dooberName);
                                                };
                                                break;
                                            default:
                                                dooberAmount = (dooberAmount * multiplier);
                                                dooberName = Global.gameSettings.getDooberFromType(dooberName, Math.ceil(dooberAmount));
                                                isValidDoober = true;
                                        };
                                        if (isValidDoober){
                                            doobersArray.push(new Array(dooberName, dooberAmount, object));
                                        };
                                    };
                                    found = true;
                                };
                            };
                        };
                    };
                };
            };
            return (doobersArray);
        }
        public function forceServerStats():void{
            var _local1:Object = TFarmTransaction.gamedata;
            if (_local1 == null){
                return;
            };
            Global.player.gold = int(_local1.coins);
            Global.player.xp = int(_local1.xp);
            Global.player.rollCounter = int(_local1.roll);
            Global.player.updateEnergy((int(_local1.energy) - Global.player.energy), new Array("energy", "set_from_server", "", ""));
        }
        public function get rollCounter():int{
            return (this.m_randomRollCounter);
        }
        public function set rollCounter(_arg1:int):void{
            this.m_randomRollCounter = _arg1;
        }
        public function get rollCounterMap():Dictionary{
            return (this.m_randomRollCounterMap);
        }
        public function setRollCounterValue(_arg1:String, _arg2:int):void{
            this.m_randomRollCounterMap[_arg1] = _arg2;
        }
        public function getFlag(_arg1:String):Flag{
            var _local2:Flag = this.m_flagContainer[_arg1];
            if (!_local2){
                _local2 = new Flag(_arg1);
                this.m_flagContainer[_arg1] = _local2;
            };
            return (_local2);
        }
        public function setFlag(_arg1:String, _arg2:Number):void{
            var _local3:Flag = this.m_flagContainer[_arg1];
            if (!_local3){
                _local3 = new Flag(_arg1);
                this.m_flagContainer[_arg1] = _local3;
            };
            _local3.value = _arg2;
        }
        public function allowQuests():Boolean{
            return (this.m_allowQuests);
        }
        public function setAllowQuests(_arg1:Boolean):void{
            this.m_allowQuests = _arg1;
        }
        public function get collections():Object{
            return (this.m_collections);
        }
        public function getNumCollectablesOwned(_arg1:String):int{
            var _local2:String = Global.gameSettings.getCollectionByCollectableName(_arg1).name;
            if (((this.m_collections.hasOwnProperty(_local2)) && (this.m_collections[_local2].hasOwnProperty(_arg1)))){
                return (this.m_collections[_local2][_arg1]);
            };
            return (0);
        }
        public function removeCollectable(_arg1:String):void{
            var _local2:String = Global.gameSettings.getCollectionByCollectableName(_arg1).name;
            if (((this.m_collections.hasOwnProperty(_local2)) && (this.m_collections[_local2].hasOwnProperty(_arg1)))){
                this.m_collections[_local2][_arg1] = (this.m_collections[_local2][_arg1] - 1);
                if (this.m_collections[_local2][_arg1] <= 0){
                    delete this.m_collections[_local2][_arg1];
                };
            };
        }
        public function addCollectable(_arg1:String):void{
            var _local2:String = Global.gameSettings.getCollectionByCollectableName(_arg1).name;
            if (!this.m_collections.hasOwnProperty(_local2)){
                this.m_collections[_local2] = new Object();
            };
            if (this.m_collections[_local2][_arg1]){
                this.m_collections[_local2][_arg1] = (this.m_collections[_local2][_arg1] + 1);
            } else {
                this.m_collections[_local2][_arg1] = 1;
            };
        }
        public function trackTradeIns(_arg1:String):void{
            if (!this.m_collectionTradeIns.hasOwnProperty(_arg1)){
                this.m_collectionTradeIns[_arg1] = 0;
            };
            var _local2 = this.m_collectionTradeIns;
            var _local3 = _arg1;
            var _local4 = (_local2[_local3] + 1);
            _local2[_local3] = _local4;
        }
        public function numTradeIns(_arg1:String):int{
            return ((this.m_collectionTradeIns[_arg1]) ? this.m_collectionTradeIns[_arg1] : 0);
        }
        public function getMasteryLevel(_arg1:String):int{
            var _local2:int;
            if (this.m_completedCollections[_arg1] != null){
                _local2 = this.m_completedCollections[_arg1];
            };
            return (_local2);
        }
        public function completeCollection(_arg1:String):void{
            if (this.m_completedCollections[_arg1] == null){
                this.m_completedCollections[_arg1] = 1;
            } else {
                var _local2 = this.m_completedCollections;
                var _local3 = _arg1;
                var _local4 = (_local2[_local3] + 1);
                _local2[_local3] = _local4;
            };
        }
        public function hasCompletedCollection(_arg1:String):Boolean{
            return ((this.m_completedCollections[_arg1] > 0));
        }
        public function addToWishlist(_arg1:String):void{
            if (this.isItemOnWishlist(_arg1) == false){
                this.wishlist.push(_arg1);
            };
        }
        public function removeFromWishlist(_arg1:String):void{
            var _local2:int = this.wishlist.indexOf(_arg1);
            if (_local2 >= 0){
                this.wishlist.splice(_local2, 1);
            };
        }
        public function canAddToWishlist(_arg1:String):Boolean{
            var _local2:Boolean;
            var _local3:Item = Global.gameSettings.getItemByName(_arg1);
            if (((!(_local3.xml.playerLocked)) || (!((_local3.xml.playerLocked == "false"))))){
                _local2 = ((!(this.isItemOnWishlist(_arg1))) && (!(this.isWishlistFull())));
            };
            return (_local2);
        }
        public function isItemOnWishlist(_arg1:String):Boolean{
            return ((this.wishlist.indexOf(_arg1) >= 0));
        }
        public function isWishlistFull():Boolean{
            return ((this.wishlist.length >= Global.gameSettings.getInt("wishlistSize", 5)));
        }
        public function isMusicDisabled():Boolean{
            if (!this.m_options.hasOwnProperty("musicDisabled")){
                return (true);
            };
            return (this.m_options.musicDisabled);
        }
        public function getTradeableCollections():Array{
            var _local2:XML;
            var _local3:Collection;
            var _local1:Array = [];
            for each (_local2 in Global.gameSettings.getCollections()) {
                _local3 = new Collection(_local2);
                if (_local3.getCurrentUniqueCollectablesCount() == _local3.getTotalCollectablesCount()){
                    _local1.push(_local3);
                };
            };
            return (_local1);
        }
        public function isEligibleForBusinessUpgrades():Boolean{
            return ((((this.level >= Global.gameSettings.getInt("businessUpgradesRequiredLevel", 15))) && ((Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_BUSINESS_UPGRADES) > 0))));
        }
        public function getLastActivationTime(_arg1:String):int{
            _arg1 = _arg1.slice(0, 25);
            if (this.m_playerTimestamps[_arg1]){
                return (this.m_playerTimestamps[_arg1]);
            };
            return (-1);
        }
        public function setLastActivationTime(_arg1:String, _arg2:int):void{
            _arg1 = _arg1.slice(0, 25);
            this.m_playerTimestamps[_arg1] = _arg2;
            GameTransactionManager.addTransaction(new TUpdatePlayerTimestamp(_arg1));
        }
        public function get heldEnergy():Number{
            return (this.m_heldEnergy);
        }
        public function set heldEnergy(_arg1:Number):void{
            this.m_heldEnergy = _arg1;
        }
        public function get compensationFlag():int{
            return (this.m_compensationFlag);
        }
        public function set compensationFlag(_arg1:int):void{
            this.m_compensationFlag = _arg1;
        }
        public function get savedQuestSequence():Array{
            return (this.m_savedQuestSequence);
        }
        public function get questManagerQuests():Array{
            return (this.m_questManagerQuests);
        }
        public function saveQuestOrderSequence():void{
            var _local1:int = Global.experimentManager.getVariant(ExperimentDefinitions.EXPERIMENT_QUEST_MANAGER);
            if (_local1 == ExperimentDefinitions.NO_QUEST_MANAGER){
                return;
            };
            var _local2:HUDQuestBarComponent = (Global.hud.getComponent(HUD.COMP_QUESTS) as HUDQuestBarComponent);
            var _local3:int;
            while (_local3 < _local2.questNames.length) {
                this.m_savedQuestSequence[_local3] = _local2.questNames[_local3];
                _local3++;
            };
            _local3 = 0;
            while (_local3 < UI.questManagerView.content.model.size()) {
                this.m_questManagerQuests[_local3] = (UI.questManagerView.content.model.getElementAt(_local3) as QuestManagerSprite).name;
                _local3++;
            };
            TransactionManager.addTransaction(new TUpdateSavedQuestOrder(this.m_savedQuestSequence, this.m_questManagerQuests));
        }
        public function getSavedQuestSlot(_arg1:String):int{
            return (this.m_savedQuestSequence.indexOf(_arg1));
        }
        public function wasInQuestManager(_arg1:String):Boolean{
            return ((this.m_questManagerQuests.indexOf(_arg1) >= 0));
        }
        public function set numQuestsLoading(_arg1:int):void{
            this.m_numQuestsLoading = _arg1;
        }
        public function get numQuestsLoading():int{
            return (this.m_numQuestsLoading);
        }
        public function get isPremiumGoodsActive():Boolean{
            if (Global.questManager == null){
                return (false);
            };
            if (Global.questManager.isFlagReached(GameQuestManager.QUEST_UX_PREMIUM_GOODS_UNLOCKED)){
                return (true);
            };
            if (Factory.isFactoryInPlayerWorld()){
                return (true);
            };
            return (false);
        }
        public function getShowMFIByID(_arg1:String):Boolean{
            return (this.m_showMFI[_arg1]);
        }
        public function setShowMFIByID(_arg1:String, _arg2:Boolean):void{
            this.m_showMFI[_arg1] = _arg2;
        }
        public function get MFIDict():Dictionary{
            return (this.m_showMFI);
        }
        public function get npc_cloud_visible():Boolean{
            return (this.m_npc_cloud_visible);
        }
        public function allowRightSideBuild():Boolean{
            return ((Global.player.getFlag("completed_bridge").value == 1));
        }
        public function setAllowRightSideBuild():void{
            Global.player.setFlag("completed_bridge", 1);
        }

    }
}//package Classes 
